import React, { Component } from "react";
import { connect } from "react-redux";
import Form from "./Form";
import List from "./List";
import { addAction } from "./store/actionCreator";

const mapStateToProps = (state) => {
  return {
    count: state.count,
  };
};

const mapDispatchToProps = (dispatch) => {
  return {
    add() {
      // dispatch({ type: "add" });
      dispatch(addAction());
    },
  };
};

@connect(mapStateToProps, mapDispatchToProps)
class App extends Component {
  state = {};
  render() {
    return (
      <>
        <h2>redux-todolist-thunk</h2>
        <span>{this.props.count}</span>
        <button onClick={this.props.add}>+</button>
        <hr />
        <Form />
        <List />
      </>
    );
  }
}

export default App;
